import axios from '@/utils/request';

/**
 * 查询所有账户信息列表
 */
export async function AllAccount(params) {
  const res = await axios.post('/Account/QueryAccountViewByCondition',params);
  if (res.data.code === 200) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}
/**
 * 查询所有账户信息列表
 */
 export async function QueryAccountList() {
  const res = await axios.get('/Account/QueryAccountList');
  if (res.data.code === 200) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

/**
 * 添加账户
 * @param data 
 */
export async function AddAccount(data) {
  const res = await axios.post('/Account/AddAccount', data);
  if (res.data.code === 200) {
    return res.data.msg;
  }
  return Promise.reject(new Error(res.data.msg));
}

/**
 * 修改账户
 * @param data 账户信息
 */
export async function UpdateAccount(data) {
  const res = await axios.post('/Account/UpdateAccount', data);
  if (res.data.code === 200) {
    return res.data.msg;
  }
  return Promise.reject(new Error(res.data.msg));
}

/**
 * 根据组账户Id删除账户信息
 */
 export async function DeleteAccount(id) {
  const res = await axios.get('/Account/DeleteAccount?id='+id);
  if (res.data.code === 200) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}
/**
 * 根据组账户Id获取账户信息
 */
 export async function GetModelById(id) {
  const res = await axios.get('/Account/QueryCurrentAccountById?id='+id);
  if (res.data.code === 200) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

/**
 * 删除账户
 * @param id 账户id
 */
export async function RemoveRole(id) {
  const res = await axios.get('/Account/DeleteAccount/' + id);
  if (res.data.code === 200) {
    return res.data.msg;
  }
  return Promise.reject(new Error(res.data.msg));
}

/**
 * 重置密码
 * @param id 账户id
 */
 export async function ResetPassword(data) {
  const res = await axios.post('/Account/ResetPassword',data);
  if (res.data.code === 200) {
    return res.data.msg;
  }
  return Promise.reject(new Error(res.data.msg));
}
